//show properties
function fmdpf_showprop(compType, type, $obj) {
	//console.debug("fmdpf_showprop compType="+compType+" type="+type);
	var ts = new Date();
	fmdc.grid_prop || fmdpf_initPropGridLayout();
	fmdc.proptemp = {"compType" : compType, "type" : type};
	fmdpf_parse_prop_bytype(compType, type);
	fmdc.grid_prop.enableValidation(true, true);
	designer.isEditor() && designer.enableApply(fmdmeta_prop[compType][type].onApply);
	//bind grid events
	fmdpf_bindGridEvents(fmdmeta_prop[compType][type].propDhxGridEvents);
	fmdc.cell_prop.expand();
	fmdc.cell_prop.setWidth(fmdc.cell_prop_width);
	//set existing data
	fmdpf_loadExisting($obj);
	//fmdc.grid_prop.expandAll();
	var te = new Date();
	console.debug("fmdpf_showprop "+$obj.attr("id")+" ellapsed------------------"+(te.getTime() - ts.getTime())+" milliseconds.");
}

//hide element properties
function fmdpf_hide_elemprop() {
	fmdc.autohideprop && fmdpf_clear_elemprop() && fmdc.cell_prop.collapse();
}

//init properties grid
function fmdpf_initPropGridLayout() {
	//fmdc.grid_prop && fmdc.grid_prop.destructor();
	fmdc.grid_prop = fmdc.cell_prop.attachGrid();
	fmdc.grid_prop.isEditor = designer.isEditor();
	fmdmeta_prop.gridconf.treeIconPath && fmdc.grid_prop.setIconPath(resloc + fmdmeta_prop.gridconf.treeIconPath);
	fmdmeta_prop.gridconf.treeImagePath && fmdc.grid_prop.setImagePath(resloc + fmdmeta_prop.gridconf.treeImagePath);
	fmdmeta_prop.gridconf.extIconPath && (fmdc.grid_prop.extIconPath = resloc + fmdmeta_prop.gridconf.extIconPath);
	fmdmeta_prop.gridconf.header && fmdc.grid_prop.setHeader(fmdmeta_prop.gridconf.header);
	fmdmeta_prop.gridconf.subHeader && fmdc.grid_prop.attachHeader(fmdmeta_prop.gridconf.subHeader);
	fmdmeta_prop.gridconf.colType && fmdc.grid_prop.setColTypes(fmdmeta_prop.gridconf.colType);
	fmdmeta_prop.gridconf.colIds && fmdc.grid_prop.setColumnIds(fmdmeta_prop.gridconf.colIds);
	fmdmeta_prop.gridconf.colAlign && fmdc.grid_prop.setColAlign(fmdmeta_prop.gridconf.colAlign);
	fmdmeta_prop.gridconf.colVAlign && fmdc.grid_prop.setColVAlign(fmdmeta_prop.gridconf.colVAlign);
	fmdmeta_prop.gridconf.colSorting && fmdc.grid_prop.setColSorting(fmdmeta_prop.gridconf.colSorting);
	fmdmeta_prop.gridconf.colMinWidth && fmdc.grid_prop.setColumnMinWidth(fmdmeta_prop.gridconf.colMinWidth);
	fmdmeta_prop.gridconf.colInitWidth && fmdc.grid_prop.setInitWidths(fmdmeta_prop.gridconf.colInitWidth);
	fmdmeta_prop.gridconf.resize && fmdc.grid_prop.enableResizing(fmdmeta_prop.gridconf.resize);
	fmdmeta_prop.gridconf.visibile && fmdc.grid_prop.setColumnsVisibility(fmdmeta_prop.gridconf.visibile);
	fmdmeta_prop.gridconf.isTreeGrid && fmdc.grid_prop.enableTreeCellEdit(false);
	fmdmeta_prop.gridconf.colColor && fmdc.grid_prop.setColumnColor(fmdmeta_prop.gridconf.colColor);
	fmdmeta_prop.gridconf.enableTooltips && fmdc.grid_prop.enableTooltips(fmdmeta_prop.gridconf.enableTooltips);
	fmdc.grid_prop.enableMultiselect(false);//单选
	fmdc.grid_prop.enableMarkedCells(true);
	fmdc.grid_prop.enableAlterCss("grid_even_row","grid_odd_row");
	fmdc.grid_prop.enableEditEvents(fmdc.grid_prop.isEditor,false,false);
	fmdc.grid_prop.setEditable(fmdc.grid_prop.isEditor);
	fmdc.grid_prop.init();
}

//hide element properties
function fmdpf_clear_elemprop() {
	//fmdc.cell_prop.attachHTMLString('');
	fmdc.grid_prop.destructor();
	fmdc.grid_prop = null;
	//fmdpf_unbindGridEvents();
	fmdc.proptemp = null;
}

//parse element properties config
function fmdpf_parse_prop_bytype(compType, type) {
	
	//parse include properties
	if (fmdmeta_prop[compType][type]["includes-properties"]) {
		for (var i in fmdmeta_prop[compType][type]["includes-properties"]) {
			//splitter row
			fmdpf_addTipRow("tiprow_"+i, eval("fmd_i18n_prop_tip_"+i));
			if (fmdmeta_prop[compType][type]["includes-properties"][i]) {
				for (var id in fmdmeta_prop[compType][type]["includes-properties"][i]) {
					if (fmdmeta_prop[compType][type]["abandon-properties"] && fmdmeta_prop[compType][type]["abandon-properties"].indexOf(id)>=0) {
						continue;
					}
					fmdpf_parsePropByCellType(0, id, fmdmeta_prop[compType][type]["includes-properties"][i][id]);
				}
			}
		}
	}
	
	//parse specific properties
	if (fmdmeta_prop[compType][type].properties) {
		//splitter row
		fmdpf_addTipRow("tiprow_specific", fmd_i18n_prop_tip_specific);
		for (var id in fmdmeta_prop[compType][type].properties) {
			fmdpf_parsePropByCellType(0, id, fmdmeta_prop[compType][type].properties[id]);
		}
	}
	
	//abandon properties
	if (fmdmeta_prop[compType][type]["abandon-properties"] && fmdmeta_prop[compType][type]["abandon-properties"].length) {
		for (var i in fmdmeta_prop[compType][type]["abandon-properties"]) {
			fmdc.grid_prop.deleteRow(fmdmeta_prop[compType][type]["abandon-properties"][i]);
		}
	}
	
	//====events
	
	//splitter row
	fmdpf_addTipRow("tiprow_events", fmd_i18n_prop_tip_events);
	!fmdc.advancedview && fmdc.grid_prop.setRowHidden("tiprow_events", true);
	
	//parse includes events
	var allevents = {};
	if (fmdmeta_prop[compType][type]["includes-events"]) {
		for (var i in fmdmeta_prop[compType][type]["includes-events"]) {
			if (fmdmeta_prop[compType][type]["includes-events"][i]) {
				for (var id in fmdmeta_prop[compType][type]["includes-events"][i]) {
					if (fmdmeta_prop[compType][type]["abandon-events"] && fmdmeta_prop[compType][type]["abandon-events"].indexOf(id)>=0) {
						continue;
					}
					allevents[id] = fmdmeta_prop[compType][type]["includes-events"][i][id];
				}
			}
		}
	}
	
	//parse specific events
	if (fmdmeta_prop[compType][type].events) {
		for (var id in fmdmeta_prop[compType][type].events) {
			allevents[id] = fmdmeta_prop[compType][type].events[id];
		}
	}
	
	//parse force show events
	var fearr = fmdmeta_prop[compType][type]["forceshow-events"] || [];
	
	//parse all events
	for (var id in allevents) {
		var forceshow = fearr.indexOf(id)>-1;
		fmdpf_parseEventByCellType(0, id, allevents[id], forceshow);
	}
	
	//abandon events
	if (fmdmeta_prop[compType][type]["abandon-events"] && fmdmeta_prop[compType][type]["abandon-events"].length) {
		for (var i in fmdmeta_prop[compType][type]["abandon-events"]) {
			fmdc.grid_prop.deleteRow(fmdmeta_prop[compType][type]["abandon-events"][i]);
		}
	}
}

//parse element properties config
/*function fmdpf_parse_prop(propconf, abp) {
	if (!propconf) return;
	//properties
	if (propconf.properties && propconf.properties.length) {
		for (var id in propconf.properties) {
			fmdpf_parsePropByCellType(0, id, propconf.properties[id]);
		}
	}
	//events
	if (propconf.events && propconf.events.length) {
		for (var id in propconf.events) {
			//fmdpf_parseEventByCellType(0, id, propconf.events[id]);
		}
	}
	//abandon properties and events
	if (propconf["abandon-properties"] && propconf["abandon-properties"].length) {
		for (var i in propconf["abandon-properties"]) {
			fmdc.grid_prop.deleteRow(propconf["abandon-properties"][i]);
		}
	}
}*/

//parse cellType
function fmdpf_parsePropByCellType(pid, id, propconf, hide) {
	//console.debug("pid="+pid+" id:"+id+" propconf="+JSON.stringify(propconf));
	var defaultVal = null;
	var imgName = propconf.img ? propconf.img : "property.png";
	
	if (propconf.value) {
		if (typeof(propconf.value)=='function') {//from function
			defaultVal = propconf.value();//如果值为function格式，采用返回值
		} else if (propconf.value["fromattr"]!=undefined) {//from attribute
			defaultVal = designer.getSelected().attr(propconf.value["fromattr"]);
		} else if (propconf.value["default"]!=undefined) {//default value
			defaultVal = propconf.value["default"];
		}
	}
	//init value if it does not exist
	if(fmdc.version.formdata.propconf[designer.getSelected().attr("id")][id]===undefined) {
		fmdc.version.formdata.propconf[designer.getSelected().attr("id")][id] = defaultVal;
	}
	
	//propconf.value?(propconf.value["default"]!=undefined)?propconf.value["default"]:"":"";
	//console.debug(propconf.name+" default value:"+defaultVal+"  afterProperty="+propconf.afterProperty);
	if (propconf.afterProperty) {
		fmdc.grid_prop.addRowAfter(id, 
				[propconf.name, defaultVal],
				propconf.afterProperty);
	} else {
		fmdc.grid_prop.addRow(id, 
				[propconf.name, defaultVal],
				null,
				pid);
	}
	//add row attribute displayOnly
	propconf.displayOnly && fmdc.grid_prop.setRowAttribute(id, "displayOnly", propconf.displayOnly);
	//set image
	fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.prop).setImage(resloc+fmdmeta_prop.iconpath+imgName);
	//console.debug(id+"="+fmdmeta_prop.gridconf.idx.value+"="+(propconf.cellType || "ed"));
	if (propconf.cellType) {
		if (typeof(propconf.cellType)=="string") {
			fmdc.grid_prop.setCellExcellType(id, fmdmeta_prop.gridconf.idx.value, propconf.cellType || "ed");
			"ro"==propconf.cellType && fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setBgColor("#F8F8F8");
		} else if (typeof(propconf.cellType)=="object") {
			if ("coro"==propconf.cellType.type) {//只读下拉列表
				var options1 = typeof(propconf.cellType.options)=='function' ? propconf.cellType.options() 
						: (typeof(propconf.cellType.options)=="string" ? eval(propconf.cellType.options) : propconf.cellType.options);
				if (propconf.cellType.readOnly) {
					fmdc.grid_prop.setCellExcellType(id, fmdmeta_prop.gridconf.idx.value, "rocoro");
					fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setOptions(options1);
					propconf.cellType.optionWidth && fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setOptionWidth(propconf.cellType.optionWidth);
				} else {
					fmdc.grid_prop.grid_bindCombo(id, 
							fmdmeta_prop.gridconf.idx.value, 
							options1, 
							{"comboSize":10, "comboWidth":propconf.cellType.optionWidth}, 
							defaultVal);
				}
			} else if ("btnex"==propconf.cellType.type) {//弹出式选择框
				fmdc.grid_prop.setCellExcellType(id, fmdmeta_prop.gridconf.idx.value, propconf.cellType.type);
			} else if ("colist"==propconf.cellType.type) {//多选列表
				fmdc.grid_prop.setCellExcellType(id, fmdmeta_prop.gridconf.idx.value, propconf.cellType.type);
			} else {//其他
				fmdc.grid_prop.setCellExcellType(id, fmdmeta_prop.gridconf.idx.value, propconf.cellType.type);
			}
			//set configs if has, some excel type has setConfig function
			propconf.cellType.config && fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setConfig && fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setConfig(propconf.cellType.config);
		}
	}
	//set validate if has
	propconf.validator && fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setAttribute("validate", propconf.validator);
	//set arguments if has, some excell type has setArgs function
	propconf.arguments && fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setArgs && fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setArgs(propconf.arguments);
	//set params if has, some excell type has setParams function
	propconf.params && fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setParams && fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setParams(propconf.params);
	//set configs if has, some excel type has setConfig function
	propconf.config && fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setConfig && fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setConfig(propconf.config);
	
	//set value
	fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setValue(defaultVal);
	
	//add sub
	if (propconf.sub) {
		for (var sid in propconf.sub) {
			fmdpf_parsePropByCellType(id, sid, propconf.sub[sid]);
		}
		fmdc.grid_prop.openItem(id);
	}
	//add conditional-sub and hide
	if (propconf["conditional-sub"]) {
		for (var sid in propconf["conditional-sub"]) {
			for (var ssid in propconf["conditional-sub"][sid]) {
				fmdpf_parsePropByCellType(id, ssid, propconf["conditional-sub"][sid][ssid], true);
			}
		}
		fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.prop).cell.firstChild.firstChild.style.visibility="hidden";
	}
	//set tooltip
	propconf.tooltip && $(fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.prop).cell).find("div:nth-child(1)").attr("original-title", propconf.tooltip).tipsy({gravity: 'e'});
	//set row hidden
	fmdc.grid_prop.setRowHidden(id, hide);
}

//parse event by cellType
function fmdpf_parseEventByCellType(pid, id, propconf, forceshow) {
	//console.debug("pid="+pid+" id:"+id+" propconf="+JSON.stringify(propconf));
	fmdc.grid_prop.addRow(id, 
			[propconf.name + "("+id+")", null],
			null,
			pid);
	//add row attribute isEvent=true
	fmdc.grid_prop.setRowAttribute(id, "isEvent", true);
	//set image
	var imgName = propconf.img ? propconf.img : "event.png";
	fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.prop).setImage(resloc+fmdmeta_prop.iconpath+imgName);
	//set excell type
	fmdc.grid_prop.setCellExcellType(id, fmdmeta_prop.gridconf.idx.value, "ace_javascript");
	propconf.arguments && fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setArgs(propconf.arguments);
	
	//add sub
	if (propconf.sub) {
		for (var sid in propconf.sub) {
			fmdpf_parsePropByCellType(id, sid, propconf.sub[sid], !fmdc.advancedview);
		}
		fmdc.advancedview && fmdc.grid_prop.openItem(id);
	}
	
	//only show in advanced view
	var show1 = forceshow || fmdc.advancedview;
	if (!show1) fmdc.grid_prop.setRowHidden(id, true);
}

//add tip row
function fmdpf_addTipRow(rid, text) {
	var rn = fmdc.grid_prop.getRowsNum();
	var prid = fmdc.grid_prop.getRowId(rn-1);
	if (rn && fmdc.grid_prop.getRowAttribute(prid, "displayOnly") && prid.indexOf("tiprow_")>=0) {//avoid duplicate tip row together
		fmdc.grid_prop.cells(prid, fmdmeta_prop.gridconf.idx.prop).setValue(text);
		fmdc.grid_prop.setRowId(fmdc.grid_prop.getRowIndex(prid), rid);
	} else {
		fmdc.grid_prop.addRow(rid, [text, ""]);
		fmdc.grid_prop.setRowAttribute(rid, "displayOnly", true);
		fmdc.grid_prop.setRowColor(rid, fmdmeta_prop.gridconf.tiprowbgcolor);
		fmdc.grid_prop.setCellExcellType(rid, fmdmeta_prop.gridconf.idx.prop, "ro");
	}
}

//collect properties values
function fmdpf_collectValues() {
	var vals = {};
	fmdc.grid_prop.forEachRow(function(id){
		if (//!fmdc.grid_prop.isRowHidden(id) && 
			!fmdc.grid_prop.getRowAttribute(id, "displayOnly") ) {
			if (fmdc.grid_prop.getRowAttribute(id, "isEvent")) {
				var arguments = "";//get arguments for function signature
				var args = fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).getArgs();
				if (args) {
					for (a in args) {
						if (arguments) arguments += ",";
						arguments += a;
					}
				}
				vals[id]={"proptype":"event", 
						"value":fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).getValue(),
						"arguments":arguments};
			} else {
				vals[id]=fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).getValue();
			}
		}
	});
	//console.debug("fmdpf_collectValues vals="+JSON.stringify(vals));
	fmdc.version.formdata.propconf[designer.getSelected().attr("id")] = vals;
}

//load existing properties values
function fmdpf_loadExisting($obj) {
	var existingConf = fmdc.version.formdata.propconf[$obj.attr("id")];
	//console.debug("existingConf="+JSON.stringify(existingConf));
	if (existingConf) {
		for (var id in existingConf) {
			//console.log(id + "==" + existingConf[id]);
			//only set existing properties that are available at this time
			if (fmdc.grid_prop.doesRowExist(id)) {
				if (existingConf[id] && typeof(existingConf[id])=='object' && existingConf[id].proptype=="event") {
					fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setValue(existingConf[id].value || "");
				} else {
					fmdc.grid_prop.cells(id, fmdmeta_prop.gridconf.idx.value).setValue(existingConf[id]);
				}
			}
		}
	}
}

//do apply
function fmdpf_apply() {
	if (!fmdpf_validate()) {
		var ve = {"id":fmdc.validateErr.length+1, "data":[fmdc.proptemp["compType"],fmdc.proptemp["type"]]};
		var msg = fmd_i18n_prop_msg_validatefail +'<br/>';
		if (fmdc.proptemp.vfailure) {
			for (var rid in fmdc.proptemp.vfailure) {
				msg += '<br/>' + fmdc.proptemp.vfailure[rid];
				ve.data.push(rid);
				ve.data.push(fmdc.proptemp.vfailure[rid]);
			}
		}
		dhtmlx.message(msg);
		fmdc.validateErr.push(ve);
		//return false;
	}
	fmdpf_collectValues();
	//alert("fmdpf_apply fmdc.proptemp="+JSON.stringify(fmdc.proptemp));
	fmdmeta_prop[fmdc.proptemp["compType"]][fmdc.proptemp["type"]].onApply && fmdmeta_prop[fmdc.proptemp["compType"]][fmdc.proptemp["type"]].onApply();
	fmdc.unsavedchange = true;
	return true;
}

//do validation
function fmdpf_validate() {
	var result = true;
	fmdc.grid_prop.forEachRow(function(rid) {
		if (!fmdc.grid_prop.isRowHidden(rid)
				 && !fmdc.grid_prop.getRowAttribute(rid, "displayOnly")
				 && false === fmdc.grid_prop.validateCell(rid, fmdmeta_prop.gridconf.idx.value)) {
			result = false;
			fmdc.proptemp.vfailure || (fmdc.proptemp.vfailure={});
			fmdc.proptemp.vfailure[rid] = this.cells(rid, fmdmeta_prop.gridconf.idx.prop).getValue();
		} else {
			fmdc.proptemp.vfailure && (delete fmdc.proptemp.vfailure[rid]);
		}
	});
	//result && (delete fmdc.proptemp.vfailure);
	return result;
}

//bind events for prop grid
function fmdpf_bindGridEvents(events) {
	//bind validation event at first
	//fmdc.grid_prop.attachEvent("onValidationError", fmdpf_onValidationError);
	//fmdc.grid_prop.attachEvent("onLiveValidationError", fmdpf_onValidationError);
	//fmdc.proptemp.propDhxGridEvents = [];
	if (fmdmeta_prop.propDhxGridPredefinedEvents) {
		for (var e in fmdmeta_prop.propDhxGridPredefinedEvents) {
			fmdc.grid_prop.attachEvent(e, fmdmeta_prop.propDhxGridPredefinedEvents[e]);
			//fmdc.proptemp.propDhxGridEvents.push(e);
		}
	}
	if (events) {
		for (var e in events) {
			fmdc.grid_prop.attachEvent(e, events[e]);
			//fmdc.proptemp.propDhxGridEvents.push(e);
		}
	}
}

//unbind events for prop grid
function fmdpf_unbindGridEvents() {
	/*console.debug("fmdc.proptemp.propDhxGridEvents="+JSON.stringify(fmdc.proptemp.propDhxGridEvents));
	if (!fmdc.proptemp.propDhxGridEvents) return;
	for (var e in fmdc.proptemp.propDhxGridEvents) {
		fmdc.grid_prop.detachEvent(fmdc.proptemp.propDhxGridEvents[e]);
	}*/
	fmdc.grid_prop.detachAllEvents();
}

//add conditional sub
/*function fmdpf_showConditionalSub(rId, nv, propconf) {
	console.debug("rId="+rId+" nv="+nv+" propconf="+JSON.stringify(propconf));
	if (fmdc.grid_prop.getRowById(rId).style.display!="none" && propconf["conditional-sub"]) {
		for (var id in propconf["conditional-sub"][nv]) {
			fmdc.grid_prop.setRowHidden(id, false);
		}
		fmdc.grid_prop.forEachRow(function(id) {
			fmdc.grid_prop.setRowHidden(id, !propconf["conditional-sub"][nv][id]);
		});
		var hasSub = false;
		var sids = fmdc.grid_prop.getSubItems(rId);
		if (sids) {
			var sida = sids.split(",");
			for (var i in sida) {
				var show = propconf["conditional-sub"][nv] && propconf["conditional-sub"][nv][sida[i]];
				fmdc.grid_prop.setRowHidden(sida[i], !show);
				show && (hasSub = true);
			}
			fmdc.grid_prop.closeItem(rId);
		}
		hasSub && fmdc.grid_prop.openItem(rId);
	} else {
		var sids = fmdc.grid_prop.getSubItems(rId);
		if (sids) {
			var sida = sids.split(",");
			for (var i in sida) {
				fmdc.grid_prop.setRowHidden(sida[i], true);
			}
			fmdc.grid_prop.closeItem(rId);
		}
	}
}*/
//add conditional sub
//增加条件子属性行
function fmdpf_showConditionalSub(rId, nv, propconf) {
	if (fmdc.grid_prop.getRowById(rId).style.display!="none" && propconf["conditional-sub"]) {
		var hasSub = false;
		var sids = fmdc.grid_prop.getSubItems(rId);
		if (sids) {
			var sida = sids.split(",");
			if (sida && sida.length>0 && ""!=sida[0]) {
				for (var i in sida) {
					var show = (propconf["conditional-sub"][nv] && propconf["conditional-sub"][nv][sida[i]]) || (propconf["conditional-sub"]["NotEmpty"] && propconf["conditional-sub"]["NotEmpty"][sida[i]]);
					fmdc.grid_prop.setRowHidden(sida[i], !show);
					if (show) {
						hasSub = true;
						fmdpf_showConditionalSub(sida[i], fmdc.grid_prop.cells(sida[i], fmdmeta_prop.gridconf.idx.value).getValue(), JSONSelect.match("."+sida[i], propconf)[0]);
					} else {
						//hide all sub rows
						var subsubs = fmdc.grid_prop.getAllSubItems(sida[i]).split(",");
						if (subsubs && subsubs.length>0 && ""!=subsubs[0]) {
							subsubs.forEach(function(ssid) {
								fmdc.grid_prop.setRowHidden(ssid, true);
							});
						}
					}
				}
			}
			//hasSub && fmdc.grid_prop.closeItem(rId);
		}
		hasSub && fmdc.grid_prop.openItem(rId);
	}
}

//scroll to row of specified prop
function fmdpf_scrollToProp(prop) {
	fmdc.grid_prop.selectRowById(prop,false,true);
}

//on vlidation fail
/*function fmdpf_onValidationError(rid,cid,v) {
	fmdc.proptemp.vfailure || (fmdc.proptemp.vfailure={});
	fmdc.proptemp.vfailure[rid] = this.cells(rid, fmdmeta_prop.gridconf.idx.prop).getValue();
}*/




